Skip dynamic type check in css value getters
authorAlexander Larsson <alexl@redhat.com>
Wed, 11 Jan 2017 07:51:04 +0000 (08:51 +0100)
committerAlexander Larsson <alexl@redhat.com>
Wed, 11 Jan 2017 08:20:30 +0000 (09:20 +0100)
This gets called a lot during snapshotting, and this change
alone brings down snapshot time by almost 10% in a syntethic
snapshot test.

gtk/gtkcssanimatedstyle.c
gtk/gtkcssstaticstyle.c
gtk/gtkcssstyle.c

index 1e89088a6bc176b1e5064e64cf629e96afed9be4..aadaf97173657dbbb90392e148ab3477ccd78981 100644 (file)
@@ -44,7 +44,8 @@ static GtkCssValue *
 gtk_css_animated_style_get_value (GtkCssStyle *style,
                                   guint        id)
 {
-  GtkCssAnimatedStyle *animated = GTK_CSS_ANIMATED_STYLE (style);
+  /* This is called a lot, so we avoid a dynamic type check here */
+  GtkCssAnimatedStyle *animated = (GtkCssAnimatedStyle *) style;
 
   if (animated->animated_values &&
       id < animated->animated_values->len &&
@@ -147,8 +148,6 @@ GtkCssValue *
 gtk_css_animated_style_get_intrinsic_value (GtkCssAnimatedStyle *style,
                                             guint                id)
 {
-  gtk_internal_return_val_if_fail (GTK_IS_CSS_ANIMATED_STYLE (style), NULL);
-
   return gtk_css_style_get_value (style->style, id);
 }
 
index 217bb06265739909a83005052849600fd36b3379..f8ce97003d8674cc2a6e8ef1f91ca5e184ea7385 100644 (file)
@@ -44,7 +44,8 @@ static GtkCssValue *
 gtk_css_static_style_get_value (GtkCssStyle *style,
                                 guint        id)
 {
-  GtkCssStaticStyle *sstyle = GTK_CSS_STATIC_STYLE (style);
+  /* This is called a lot, so we avoid a dynamic type check here */
+  GtkCssStaticStyle *sstyle = (GtkCssStaticStyle *) style;
 
   return sstyle->values[id];
 }
index 1d607d83674e086449629737fdfc780576a8fae8..250371f7fe8fc4b5b1ca4309e40554d9d365a758 100644 (file)
@@ -69,8 +69,6 @@ GtkCssValue *
 gtk_css_style_get_value (GtkCssStyle *style,
                           guint        id)
 {
-  gtk_internal_return_val_if_fail (GTK_IS_CSS_STYLE (style), NULL);
-
   return GTK_CSS_STYLE_GET_CLASS (style)->get_value (style, id);
 }